import { defineStore } from 'pinia'

export const useTcStore = defineStore('tc', {
  state: () => {
    return {
      selNodeArr: [],
      cmdObj: {},
      selCmdId: '0',
      longTcLog: [],
      sendTdForm: {}
    }
  },
  actions: {
    assingCmd(item) {
      const id = item['id']
      this.cmdObj[id] = Object.assign({}, item)
    },
    setSelectNode(arr) {
      this.selNodeArr = arr.filter(item => item !== 0)
    },
    setSelCmd(id) {
      this.selCmdId = id
    },
    setLongTcLog(logObj) {
      this.longTcLog.push(logObj)
    },
    setSendTdForm(formObj) {
      const keyName = formObj['id']
      this.sendTdForm[keyName] = formObj
    },
    clearSendTdForm(keyName) {
      delete this.sendTdForm[keyName]
    },
    clearSendTdFormFull() {
      this.sendTdForm = {}
    }
  }
})